//
//  ORGCareResultCell.swift
//  LongTermInsurance
//
//  Created by zolobdz on 2019/1/10.
//  Copyright © 2019年 HeChao. All rights reserved.
//

import UIKit

class ORGCareResultCell: UITableViewCell {

    lazy var fontSize: CGFloat = 13.0
    
    
    //登记序号
    lazy var registNumStaticLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.text = "登记序号："
        view.textColor = CDColor.themePink
        return view
    }()
    
    lazy var registNumDetailLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.numberOfLines = 2
        view.textColor = UIColor.black
        view.text = ""
        return view
    }()
    
    //病人姓名
    lazy var userNameStaticLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.text = "病人姓名："
        view.textColor = CDColor.grayTitleColorA
        return view
    }()
    
    lazy var userNameDetailLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.numberOfLines = 2
        view.textColor = CDColor.grayTitleColorA
        view.text = ""
        return view
    }()
    
    //机构名称
    lazy var orgNameStaticLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.text = "机构名称："
        view.textColor = CDColor.grayTitleColorA
        return view
    }()
    
    lazy var orgNameDetailLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.numberOfLines = 2
        view.textColor = CDColor.grayTitleColorA
        view.text = ""
        return view
    }()
    
    //入院时间
    lazy var inDateStaticLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.text = "入院日期："
        view.textColor = CDColor.grayTitleColorA
        return view
    }()
    
    lazy var inDateDetailLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.numberOfLines = 2
        view.textColor = CDColor.grayTitleColorA
        view.text = ""
        return view
    }()
    
    //出院日期
    lazy var outDateStaticLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.text = "出院日期："
        view.textColor = CDColor.grayTitleColorA
        return view
    }()
    
    lazy var outDateDetailLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.numberOfLines = 2
        view.textColor = CDColor.grayTitleColorA
        view.text = ""
        return view
    }()
    
    //申请序号
    lazy var applyNumStaticLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.text = "申请序号："
        view.textColor = CDColor.grayTitleColorA
        return view
    }()
    
    lazy var applyNumDetailLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.numberOfLines = 2
        view.textColor = CDColor.grayTitleColorA
        view.text = ""
        return view
    }()
    
    // mainUI
    lazy var containerView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.white
        view.layer.cornerRadius = 6.0
        return view
    }()
    
    lazy var topView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.hexString(hexString: "#88C0FF")
        view.layer.cornerRadius = 6.0
        return view
    }()
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func config(model: CareOrgResultModel) {
        registNumDetailLabel.text = "\(model.hospitalNum)"
        userNameDetailLabel.text = model.userName
        orgNameDetailLabel.text = model.orgName
        inDateDetailLabel.text = model.inDate
        outDateDetailLabel.text = model.outDate
        applyNumDetailLabel.text = "\(model.applyNum)"
    }
    
    func setupUI() {
        selectionStyle = .none
        let detailLeft = 90.0
        let verPadding = 15.0
        let leftGap = 20
        
        self.backgroundColor = UIColor.clear
        addSubview(containerView)
        addSubview(topView)
        
        containerView.snp.remakeConstraints { (make) in
            make.top.equalTo(20+10)
            make.left.equalTo(20)
            make.right.equalTo(-20)
            make.bottom.equalToSuperview()
        }
        
        topView.snp.remakeConstraints { (maker) in
            maker.left.equalTo(20)
            maker.right.equalTo(-20)
            maker.height.equalTo(40)
            maker.top.equalTo(10)
        }
        
        topView.addSubview(registNumStaticLabel)
        topView.addSubview(registNumDetailLabel)
        registNumStaticLabel.snp.remakeConstraints { (make) in
            //            make.top.equalTo(15)
            make.centerY.equalToSuperview()
            make.left.equalTo(leftGap)
        }
        registNumDetailLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(detailLeft)
            make.centerY.equalTo(registNumStaticLabel)
            make.right.equalTo(-10)
        }
        containerView.addSubview(userNameStaticLabel)
        containerView.addSubview(userNameDetailLabel)
        userNameStaticLabel.snp.remakeConstraints { (make) in
            make.top.equalTo(20 + 15)
            //            make.top.equalTo(registNumStaticLabel.snp.bottom).offset(verPadding)
            make.left.equalTo(leftGap)
        }
        userNameDetailLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(detailLeft)
            make.centerY.equalTo(userNameStaticLabel)
            make.right.equalTo(-10)
        }
        
        containerView.addSubview(orgNameStaticLabel)
        containerView.addSubview(orgNameDetailLabel)
        orgNameStaticLabel.snp.remakeConstraints { (make) in
            make.top.equalTo(userNameStaticLabel.snp.bottom).offset(verPadding)
            make.left.equalTo(leftGap)
        }
        orgNameDetailLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(detailLeft)
            make.centerY.equalTo(orgNameStaticLabel)
            make.right.equalTo(-10)
        }
        
        containerView.addSubview(inDateStaticLabel)
        containerView.addSubview(inDateDetailLabel)
        inDateStaticLabel.snp.remakeConstraints { (make) in
            make.top.equalTo(orgNameStaticLabel.snp.bottom).offset(verPadding)
            make.left.equalTo(leftGap)
        }
        inDateDetailLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(detailLeft)
            make.centerY.equalTo(inDateStaticLabel)
            make.right.equalTo(-10)
        }
        
        containerView.addSubview(outDateStaticLabel)
        containerView.addSubview(outDateDetailLabel)
        outDateStaticLabel.snp.remakeConstraints { (make) in
            make.top.equalTo(inDateStaticLabel.snp.bottom).offset(verPadding)
            make.left.equalTo(leftGap)
        }
        outDateDetailLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(detailLeft)
            make.centerY.equalTo(outDateStaticLabel)
            make.right.equalTo(-10)
        }
        
        containerView.addSubview(applyNumStaticLabel)
        containerView.addSubview(applyNumDetailLabel)
        applyNumStaticLabel.snp.remakeConstraints { (make) in
            make.top.equalTo(outDateStaticLabel.snp.bottom).offset(verPadding)
            make.left.equalTo(leftGap)
        }
        applyNumDetailLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(detailLeft)
            make.centerY.equalTo(applyNumStaticLabel)
            make.right.equalTo(-10)
        }
    }
    
    
}
